package com.wkbb.basic.feign;

import com.wkbb.common.constants.VersionConstant;
import com.wkbb.common.dto.ResultDTO;
import com.wkbb.common.dto.basic.ImRepairClassMasterDto;
import com.wkbb.common.dto.basic.MQTTMessageDto;
import com.wkbb.common.dto.basic.UserDto;
import com.wkbb.common.dto.im.*;
import com.wkbb.common.dto.sms.SmsDto;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author dengjingyuan
 * @date 2019-07-04 10:32
 */
@FeignClient(name = "wkbb-tc-cloud-service")
public interface TcCloudFeignService {

    @ApiOperation(value = "自动建群")
    @RequestMapping(value = "/tccloud/v1/im/chat/saveAutoGroup", method = RequestMethod.POST)
    ResultDTO<Object> saveAutoGroup(@RequestBody GroupUserInfoDto groupUserInfoDto);

    @ApiOperation(value = "注册IM账号")
    @RequestMapping(value = "/tccloud/v1/im/chat/getImAccount", method = RequestMethod.GET)
    ResultDTO<Object> getImAccount(
            @ApiParam(value = "接口版本", required = true) @RequestParam(name = "apiVersion", required = true) String apiVersion,
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "userId", required = true) Long orgId,
            @ApiParam(value = "角色类型(1教师2家长3学生4职员5游客)", required = true) @RequestParam(name = "roleType", required = true) Short roleType,
            @ApiParam(value = "1园长 2教师 3保育员 4 营养师 5代课教师 6其他", required = true) @RequestParam(name = "userType", required = true) Short userType
    );

    @ApiOperation(value = "账号检测(IM账号是否注册)")
    @RequestMapping(value = "/tccloud/v1/im/chat/getCheckImAccount", method = RequestMethod.GET)
    ResultDTO<Object> getCheckImAccount(
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "用户唯一值", required = false) @RequestParam(name = "userKey", required = false) String userKey,
            @ApiParam(value = "用户头像", required = true) @RequestParam(name = "userHeadUrl", required = true) String userHeadUrl,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "角色类型(1教师2家长3学生4职员5游客)", required = true) @RequestParam(name = "roleType", required = true) Short roleType,
            @ApiParam(value = "1园长 2教师 3保育员 4 营养师 5代课教师 6其他", required = true) @RequestParam(name = "userType", required = true) Short userType
    );

    @ApiOperation(value = "批量账号检测,没有的自动创建")
    @RequestMapping(value = "/tccloud/v1/im/chat/getCheckImAccountList", method = RequestMethod.POST)
     ResultDTO<Object> getCheckImAccountList(
            @RequestBody List<GroupUserInfoDto> groupUserInfoDto
    );

    @ApiOperation(value = "通过短信模板ID发送消息")
    @RequestMapping(value = "/tccloud/v1/sms/sendCloudSmsByTemId", method = RequestMethod.POST)
    ResultDTO<Object> sendCloudSmsByTemId(
            @ApiParam(value = "手机号码", required = true) @RequestParam(name = "mobile", required = true) String mobile,
            @ApiParam(value = "短信验证码来源(1,个人中心,2.人脸录入)", required = true) @RequestParam(name = "type", required = true) Integer type);

    @ApiOperation(value = "发送短信")
    @RequestMapping(value = "/tccloud/v1/sms/sendSms", method = RequestMethod.POST)
   ResultDTO<Object> sendSms(@RequestBody SmsDto smsDto);

    @ApiOperation(value = "其它网络图片路径上传到COS")
    @RequestMapping(value = "/tccloud/v1/cos/getPicUrl", method = RequestMethod.PUT)
    ResultDTO<Object> getPicUrl(
            @ApiParam(value = "SecretId", defaultValue = "www.baidu.com", required = true) @RequestParam(name = "tmpSecretId", required = true) String tmpSecretId,
            @ApiParam(value = "SecretKey", defaultValue = "www.baidu.com", required = true) @RequestParam(name = "tmpSecretKey", required = true) String tmpSecretKey,
            @ApiParam(value = "Token", defaultValue = "www.baidu.com", required = true) @RequestParam(name = "sessionToken", required = true) String sessionToken,
            @ApiParam(value = "1:考勤,2:基础,3:设备,4:动态,5:人脸,6:聊天,7:生活,8:小程序", defaultValue = "1", required = true) @RequestParam(name = "type", required = true) Integer type,
            @ApiParam(value = "1:图片,2:视频,3:文件", defaultValue = "1", required = true) @RequestParam(name = "countType", required = true) Integer countType,
            @ApiParam(value = "网络URL", required = true) @RequestParam(name = "picUrl", required = true) String picUrl);

    @ApiOperation(value = "获取临时密钥接口")
    @RequestMapping(value = "/tccloud/v1/cos/getCredential", method = RequestMethod.GET)
    ResultDTO<COSCredentialDto> getCredential(

    );

    @ApiOperation(value = "老师身份变更,修改所有群对应身份")
    @RequestMapping(value = "/tccloud/v1/im/chat/updateAllGroupUserInfo", method = RequestMethod.PUT)
    ResultDTO<Object> updateAllGroupUserInfo(
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "组织ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "角色ID", required = true) @RequestParam(name = "roleType", required = true) Integer roleType,
            @ApiParam(value = "修改前老师身份", required = true) @RequestParam(name = "oldUserType", required = true) Short oldUserType,
            @ApiParam(value = "修改老师身份", required = true) @RequestParam(name = "userType", required = true) Short userType,
            @ApiParam(value = "在本群昵称", required = true) @RequestParam(name = "relationTypeName", required = true) String relationTypeName
    );

    @ApiOperation(value = "Base64图片上传到COS")
    @RequestMapping(value = "/tccloud/v1/cos/getPicBase64", method = RequestMethod.POST)
    public ResultDTO<Object> getPicBase64(
            @ApiParam(value = "SecretId", defaultValue = "www.baidu.com", required = true) @RequestParam(name = "tmpSecretId", required = true) String tmpSecretId,
            @ApiParam(value = "SecretKey", defaultValue = "www.baidu.com", required = true) @RequestParam(name = "tmpSecretKey", required = true) String tmpSecretKey,
            @ApiParam(value = "Token", defaultValue = "www.baidu.com", required = true) @RequestParam(name = "sessionToken", required = true) String sessionToken,
            @ApiParam(value = "1:考勤,2:基础,3:设备,4:动态,5:人脸,6:聊天,7:生活,8:小程序", defaultValue = "1", required = true) @RequestParam(name = "type", required = true) Integer type,
            @ApiParam(value = "1:图片,2:视频,3:文件", defaultValue = "1", required = true) @RequestParam(name = "countType", required = true) Integer countType,
            @ApiParam(value = "图片Base64字符", required = true) @RequestParam(name = "file", required = true) String picBase64);

    @ApiOperation(value = "查询已有群的班主任列表")
    @RequestMapping(value = "/tccloud/v1/im/chat/getUserListHaveGroup", method = RequestMethod.GET)
    ResultDTO<List<UserDto>> getUserListHaveGroup();

    @ApiOperation(value = "负责人转让群主")
    @RequestMapping(value = "/tccloud/v1/im/chat/updateGroupOwner", method = RequestMethod.POST)
    ResultDTO<Object> updateGroupOwner(
            @RequestBody GroupUserInfoDto groupUserInfoDto
    );

    @ApiOperation(value = "通过用户ID查询当前所在班级自动建群群信息")
    @RequestMapping(value = "/tccloud/v1/im/chat/getAutoGroupInfo", method = RequestMethod.GET)
    ResultDTO<GroupUserInfoDto> getAutoGroupInfo(
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "班级ID", required = true) @RequestParam(name = "classId", required = true) Long classId,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "角色ID", required = true) @RequestParam(name = "roleType", required = true) Short roleType,
            @ApiParam(value = "用户类型", required = true) @RequestParam(name = "userType", required = true) Short userType
    );

    /**
     * 根据orgId,userId,roleType,userType查询IM用户
     * @return ImUserDto
     */
    @ApiOperation(value = "查询IM用户")
    @GetMapping(value = "/tccloud/v1/im/chat/getImUser")
     ResultDTO<ImUserDto> getImUser(@ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
                                          @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
                                          @ApiParam(value = "角色类型（1教师2家长3学生4职员5游客）", required = true) @RequestParam(name = "roleType", required = true) Short roleType,
                                          @ApiParam(value = "用户类型(0:家长1园长 2教师 3保育员 4 营养师 5代课教师 6其他)", required = true) @RequestParam(name = "userType", required = true) Short userType);

    @ApiOperation(value = "增加群成员(批量)")
    @RequestMapping(value = "/tccloud/v1/im/chat/saveGroupUser", method = RequestMethod.POST)
     ResultDTO<Object> saveGroupUser(
            @RequestBody List<GroupUserInfoDto> groupUserInfoDto
    );

    @ApiOperation(value = "封装园长对象并自动加入本校所有自动创建的群")
    @RequestMapping(value = "/tccloud/v1/im/chat/saveMasterGroupUserInfo", method = RequestMethod.POST)
     ResultDTO<Object> saveMasterGroupUserInfo(
            @RequestBody List<GroupUserInfoDto> groupUserInfoDto,
            @ApiParam(value = "班级ID", required = false) @RequestParam(name = "classId", required = false) Long classId,
            @ApiParam(value = "学校ID", required = false) @RequestParam(name = "orgId", required = false) Long orgId
    );

    @ApiOperation(value = "通过学校和班级ID获取自动建群群信息")
    @RequestMapping(value = "/tccloud/v1/im/chat/getAutoGroupInfoByClassId", method = RequestMethod.GET)
    public ResultDTO<GroupUserInfoDto> getAutoGroupInfoByClassId(
            @ApiParam(value = "班级ID", required = true) @RequestParam(name = "classId", required = true) Long classId,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId);

    @ApiOperation(value = "群组解散")
    @PostMapping(value = "/tccloud/v1/im/chat/destroyGroup")
    public ResultDTO<Object> destroyGroup(
            @ApiParam(value = "群组ID", required = true) @RequestParam(name = "groupId", required = true) String groupId);

    @ApiOperation(value = "删除群成员")
    @RequestMapping(value = "/tccloud/v1/im/chat/deleteeGroupUser", method = RequestMethod.POST)
    public ResultDTO<Object> deleteeGroupUser(
            @RequestBody GroupUserInfoDto groupUserInfoDto);

    @ApiOperation(value = "删除IM账号(云通信2.0提供的API接口)")
    @PostMapping(value = "/tccloud/v1/im/chat/accountDelete")
    public ResultDTO<Object> accountDelete(
            @ApiParam(value = "IM帐号对象数组", required = true) @RequestParam(name = "userKeys", required = true) List<String> userKeys);

    @ApiOperation(value = "删除IM账号(仅更新imUser表status)")
    @PostMapping(value = "/tccloud/v1/im/chat/updateImUserStatus")
    public ResultDTO updateImUserStatus(
            @ApiParam(value = "IM帐号对象数组", required = true) @RequestParam(name = "userKeys", required = true) List<String> userKeys);

    @ApiOperation(value = "修改群资料")
    @RequestMapping(value = "/tccloud/v1/im/chat/updateGroupInfo", method = RequestMethod.PUT)
     ResultDTO<Object> updateGroupInfo(
            @ApiParam(value = "班级ID", required = true) @RequestParam(name = "classId", required = true) Long classId,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "群名称", required = true) @RequestParam(name = "groupName", required = true) String groupName,
            @ApiParam(value = "自动建群标识0:手动创群,1:自动建群", required = true) @RequestParam(name = "groupIdentify", required = true) Short groupIdentify
    );

    @ApiOperation(value = "设置负责人当任所有群群主")
    @PostMapping(value = "/tccloud/v1/im/chat/setMasterGroup")
     ResultDTO<Object> setMasterGroup(
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "角色类型（1教师2家长3学生4职员5游客）", required = true) @RequestParam(name = "roleType", required = true) Short roleType,
            @ApiParam(value = "用户类型(0:家长1园长 2教师 3保育员 4 营养师 5代课教师 6其他)", required = true) @RequestParam(name = "userType", required = true) Short userType,
            @ApiParam(value = "自动建群标识0:手动创群,1:自动建群,2教职工群", required = true) @RequestParam(name = "imGroupType", required = true) Short imGroupType
    );

    @ApiOperation(value = "解决分布式事务,任课老师以及班主任入群")
    @RequestMapping(value = "/tccloud/v1/im/chat/saveAutoTeacher", method = RequestMethod.POST)
     ResultDTO<Object> saveAutoTeacher(
            @RequestBody List<GroupUserInfoDto> groupUserInfoDto
    );

    @ApiOperation(value = "修改用户资料,暂时只支持修改用户头像")
    @PostMapping(value = "/tccloud/v1/im/chat/updateImUserInfo")
     ResultDTO<Object> updateImUserInfo(
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "角色类型（1教师2家长3学生4职员5游客）", required = true) @RequestParam(name = "roleType", required = true) Short roleType,
            @ApiParam(value = "用户类型(0:家长1园长 2教师 3保育员 4 营养师 5代课教师 6其他)", required = true) @RequestParam(name = "userType", required = true) Short userType,
            @ApiParam(value = "修改后的头像地址", required = true) @RequestParam(name = "headUrl", required = true) String headUrl
    );

    @ApiOperation(value = "通过用户ID查询当前所在班级自动建群群信息(后端使用)")
    @RequestMapping(value = "/tccloud/v1/im/chat/getAutoGroupInfoManage", method = RequestMethod.GET)
     ResultDTO<GroupUserInfoDto> getAutoGroupInfoManage(
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "班级ID", required = true) @RequestParam(name = "classId", required = true) Long classId,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "角色ID", required = true) @RequestParam(name = "roleType", required = true) Short roleType,
            @ApiParam(value = "用户类型", required = true) @RequestParam(name = "userType", required = true) Short userType
    );

    @ApiOperation(value = "通过IM账号获取用户角色")
    @PostMapping(value = "/tccloud/v1/im/chat/getImUserInfoByImAccount")
     ResultDTO<List<ImUserDto>> getImUserInfoByImAccount(
            @ApiParam(value = "IM账号,多个", required = true) @RequestParam(name = "imAccounts", required = true) String imAccounts
    );

    @ApiOperation(value = "获取IM修复班级群redisKey")
    @PostMapping(value = "/tccloud/v1/im/chat/getReapirImAccountRedisKey")
    ResultDTO<Object> getReapirImAccountRedisKey(
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId
    );

    //-----------------------------------以下接口用户IM2.0修复数据使用,后续可以删除-----------------------------------------------

    @ApiOperation(value = "批量账号检测,没有的自动创建")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/getRepairCheckImAccountList", method = RequestMethod.POST)
    ResultDTO<Object> getRepairCheckImAccountList(
            @RequestBody List<GroupUserInfoDto> groupUserInfoDto
    );

    @ApiOperation(value = "负责人转让群主")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/repairUpdateGroupOwner", method = RequestMethod.POST)
     ResultDTO<Object> repairUpdateGroupOwner(
            @RequestBody GroupUserInfoDto groupUserInfoDto
    );

    @ApiOperation(value = "检测当前用户,当前学校错误的账号信息和群信息")
    @PostMapping(value = "/tccloud/v1/im/chat/repair/checkImAccountIdByUserId")
    ResultDTO<Object> checkImAccountIdByUserId(
            @RequestBody List<GroupUserInfoDto> groupUserInfoDto
    );

    @ApiOperation(value = "批量账号检测,没有的自动创建")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/getCheckImAccountByUser", method = RequestMethod.POST)
    ResultDTO<Object> getCheckImAccountByUser(
            @RequestBody List<GroupUserInfoDto> groupUserInfoDto
    );

    @ApiOperation(value = "获取IM修复班级群redisKey")
    @PostMapping(value = "/tccloud/v1/im/chat/repair/getReapirImAccountByUserRedisKey")
    ResultDTO<Object> getReapirImAccountByUserRedisKey(
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId
    );

    @ApiOperation(value = "获取IM账号缓存")
    @GetMapping(value = "/tccloud/v1/im/chat/getImUserRedis")
     ResultDTO<Object> getImUserRedis(
            @ApiParam(value = "用户ID", required = true) @RequestParam(name = "userId", required = true) Long userId,
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
            @ApiParam(value = "角色类型(1教师2家长3学生4职员5游客)", required = true) @RequestParam(name = "roleType", required = true) Short roleType,
            @ApiParam(value = "1园长 2教师 3保育员 4 营养师 5代课教师 6其他", required = true) @RequestParam(name = "userType", required = true) Short userType
    );

    @ApiOperation(value = "查询IM所有已生成的有效班级集合")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/getImClassInfo", method = RequestMethod.GET)
    ResultDTO<List<Long>> getImClassInfo();

    @ApiOperation(value = "查询已入群的家长用户ID")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/getImFamily", method = RequestMethod.GET)
    ResultDTO<List<ImUserNum>> getImFamily(@ApiParam(value = "学校ID", required = false) @RequestParam(name = "orgId", required = false) Long orgId);

    @ApiOperation(value = "查询已入群的园长用户ID")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/getImMaster", method = RequestMethod.GET)
    ResultDTO<List<Long>> getImMaster();

    @ApiOperation(value = "查询已入群的班主任和任课老师")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/getClassMasterNum", method = RequestMethod.GET)
    public ResultDTO<List<ImRepairClassMasterDto>> getClassMasterNum();

    @ApiOperation(value = "查询已入群的班主任和任课老师")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/getImMasterAndTeacherCourse", method = RequestMethod.GET)
    public ResultDTO<List<Long>> getImMasterAndTeacherCourse(
    @ApiParam(value = "班級ID", required = true) @RequestParam(name = "classId", required = true) Long classId
    );

   @ApiOperation(value = "上报访客信息")
   @RequestMapping(value = "/tccloud/v1/visitor/thirdVisitorRecord", method = RequestMethod.GET)
   public ResultDTO  thirdVisitorRecord(
           @ApiParam(value = "设备Id", required = true) @RequestParam(name = "deviceId", required = true) String deviceId,
           @ApiParam(value = "通行状态", required = true) @RequestParam(name = "passResult", required = true) String passResult,
           @ApiParam(value = "通行记录类型", required = true) @RequestParam(name = "recordType", required = true) String recordType,
           @ApiParam(value = "通行时间，unix时间戳", required = true) @RequestParam(name = "timestamp", required = true) Long timestamp,
           @ApiParam(value = "访客Id", required = true) @RequestParam(name = "visitorId", required = true) String visitorId
   );

   @ApiOperation(value = "学生家长导入IM数据创建以入群(支持多个EXCLE导入)")
   @RequestMapping(value = "/tccloud/v1/im/chat/repair/repairFamilyExcle", method = RequestMethod.POST)
   ResultDTO repairFamilyExcle(
           @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId,
           @RequestBody  List<List<GroupUserInfoDto>> repairFamilyList
   );

  @ApiOperation(value = "批量注册IM账号")
  @PostMapping(value = "/tccloud/v1/im/chat/bulkRegisterImAccount")
  ResultDTO<Object> bulkRegisterImAccount(
          @RequestBody ImBulkRegisterImAccountDto imBulkRegisterImAccount
  );

    @ApiOperation(value = "IM帐号批量注册完成的redisKey")
    @RequestMapping(value = "/tccloud/v1/im/chat/repair/getBulkRegisterImAccountRedisLock", method = RequestMethod.POST)
    ResultDTO getBulkRegisterImAccountRedisLock(
            @ApiParam(value = "学校ID", required = true) @RequestParam(name = "orgId", required = true) Long orgId
    );

    @ApiOperation(value = "获取正常IM的家长")
    @PostMapping(value = "/tccloud/v1/im/chat/repair/getFamilyImList")
    ResultDTO<List<Long>> getFamilyImList(
            @ApiParam(value = "家长ID集合", required = true) @RequestParam(name = "userIdList", required = true) List<Long>  userIdList
    );

    @ApiOperation(value = "给设备发送mqtt消息")
    @RequestMapping(value = "/tccloud/v1/mqtt/sendMqttMessageToDevice", method = RequestMethod.POST)
    ResultDTO<Object> sendMqttMessageToDevice(
            @RequestBody MQTTMessageDto mqttMessageDto,
            @ApiParam(value = "deviceCodeStr") @RequestParam(name = "deviceCodeStr", required = true) String deviceCodeStr
    );
}